package com.cjyd.hrjb.utils;

import cn.hutool.crypto.digest.DigestUtil;
import com.cjyd.hrjb.config.AdminConfig;
import org.springframework.stereotype.Component;

/**
 * Created fei wo by 2020/3/19
 */
@Component
public class CryptoUtil {

    private AdminConfig adminConfig;

    public CryptoUtil(AdminConfig adminConfig) {
        this.adminConfig = adminConfig;
    }

    /**
     * 摘要算法加密用户密码
     * @param password 用户密码
     * @return md5 password
     */
    public String cryptPassword(String password) {
       return DigestUtil.md5Hex(password+ DigestUtil.md5Hex(adminConfig.getSalt()));
    }

}
